package com.chaobl.goods.sku.mapper;

import com.chaobl.goods.sku.dto.SkuEx;
import com.chaobl.goods.sku.entity.Sku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 门店商品详细信息 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2020-04-19
 */
public interface SkuMapper extends BaseMapper<Sku> {
    @Select("SELECT \n" +
            "    catalog.catalog AS catalogName,\n" +
            "    catalog.imgUrl as catalogHeadImg,\n" +
            "    brands.brand AS brandName,\n" +
            "    spu.spuName AS spuName,\n" +
            "    spu.id AS spuId,\n" +
            "    spu.spuimg AS spuImg,\n" +
            "    spu.introduce AS spuIntroduce,\n" +
            "    spu.details AS spuDetails,\n" +
            "    sku.*\n" +
            "FROM\n" +
            "    sku\n" +
            "        LEFT JOIN\n" +
            "    spu ON sku.spu_id = spu.id\n" +
            "        LEFT JOIN\n" +
            "    brands ON spu.brand = brands.id\n" +
            "        LEFT JOIN\n" +
            "    catalog ON spu.sbtid = catalog.id\n" +
            "    \n" +
            "where sku.firmid = #{enterpriseId} and sku.shopid = #{shopId} and sku.goodsClass = ${catalogId}\n")
    List<SkuEx> listByCatalogId(@Param("enterpriseId") Integer enterpriseId, @Param("shopId") Integer shopId, @Param("catalogId") Integer catalogId);
}
